interface Account {
    abstract void query();      //询问
    abstract void update();     //更新
}
//委托类
class User implements Account {
    private String name;
    private boolean Vip;
    private int balance;
    public User(String name,boolean Vip,int balance) {
        this.name=name;
        this.Vip=Vip;
        this.balance=balance;
    }
    @Override
    public void query() {
        System.out.println(name+",您的余额是："+balance);
    }
    @Override
    public void update() {
        System.out.println(name+",您可以修改账户了。"+balance);
    }

    public String getName() {
        return name;
    }
    public boolean isVip() {
        return Vip;
    }
    public int getBalance() {
        return balance;
    }
}
//代理类
class ProxyAccount implements Account {
    private User use;
    public ProxyAccount(User use) {
        this.use=use;
    }
    @Override
    public void query() {
        if(use.isVip()==true) {
            use.query();
        }
        else {
            System.out.println(use.getName()+",请您先等候五分钟才能查询账户");
        }
    }
    @Override
    public void update() {
        if(use.isVip()==true) {
            use.update();
        }
        else {
            System.out.println(use.getName()+",请您先等候五分钟才能修改账户");
        }
    }
}
public class Test_3 {
    public static void main(String[] args) {

        Account A1 = new ProxyAccount(new User("张三",true,1000));
        A1.query();
        A1.update();
        Account A2 = new ProxyAccount(new User("李四",false,1000));
        A2.query();
        A2.update();
    }
}
